package com.ruoyi.system.wnjk.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 退款队列  //普通队列
 */
@Configuration
public class RefundMQConfig {

    // 定义退款交换机
    public static final String REFUND_EXCHANGE = "refund_exchange";

    // 定义退款队列
    public static final String REFUND_QUEUE = "refund_queue";

    @Bean
    public DirectExchange refundExchange() {
        return new DirectExchange(REFUND_EXCHANGE);
    }

    @Bean
    public Queue refundQueue() {
        return new Queue(REFUND_QUEUE, true); // true 表示持久化队列
    }

    @Bean
    public Binding refundBinding(Queue refundQueue, DirectExchange refundExchange) {
        return BindingBuilder.bind(refundQueue).to(refundExchange).with(REFUND_QUEUE);
    }

}
